package com.lbd.system.controller;

import com.lbd.base.controller.BaseController;
import com.lbd.commons.Result;
import com.lbd.commons.ResultState;
import com.lbd.system.bean.Message;
import com.lbd.system.service.MessageService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 消息
 * Created by zzl on 2016/9/27.
 */
@RestController
@RequestMapping("/message")
public class MessageController extends BaseController {
    private final Logger log = Logger.getLogger(this.getClass());
    @Autowired
    MessageService messageService;

    /**
     * 根据条件分页查询消息记录
     *
     * @param page    第几页
     * @param rows    一页多少条
     * @param message 消息
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Result list(@RequestParam(name = "page", required = false, defaultValue = "1") int page,
                       @RequestParam(name = "rows", required = false, defaultValue = "10") int rows,
                       Message message) {
        return new Result(ResultState.SUCCESS, "查询成功", messageService.findByPageConditionJpql(page, rows, message));
    }
}
